/*
 * lark firmware - used by the ar9170 wireless device
 *
 * Firmware context definition
 *
 * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef __LARKFW_LARK_H
#define __LARKFW_LARK_H

#include "generated/autoconf.h"
#include "version.h"
#include "config.h"
#include "types.h"
#include "compiler.h"
#include "fwcmd.h"
#include "hw.h"
#include "dma.h"
#include "usb.h"
#include "cmd.h"

/*
 * This platform - being an odd 32-bit architecture - prefers to
 * have 32-Bit variables.
 */

struct firmware_context_struct {
	/* timer / clocks */
	unsigned int ticks_per_usec;
	unsigned int counter;			/* main() cycles */

	/* misc */
	unsigned int watchdog_enable;
	unsigned int reboot;
	unsigned int suspend_mode;

	struct {
		/* Hardware DMA queues */
		struct q_struct tx_queue[NUM_TX_Q];	/* wlan tx queue */
		struct q_struct rx_queue[NUM_RX_Q];	/* wlan rx queue */

		unsigned int mac_reset;
		unsigned int soft_int;

		/* rx filter */
		unsigned int rx_filter;

		/* tx status */
		unsigned int tx_status_pending,
			     tx_status_head_idx,
			     tx_status_tail_idx;

	} wlan;

	struct {
		/*
		 * special buffers for command & response handling
		 *
		 * the firmware uses a sort of ring-buffer to communicate
		 * to the host.
		 */
		unsigned int resp_pending, resp_head_index, resp_tail_index;
		struct lark_rsp resp_buf[NUM_SDIO_RESP_BUFS];

		u8 out_head_index, out_tail_index, out_pending;
		struct lark_data out_buf[LARK_DATA_PAYLOAD_LEN];	/* to host */

		u8 in_head_index, in_tail_index, in_pending;
		struct lark_data in_buf[LARK_DATA_PAYLOAD_LEN];		/* from host */
	} sdio;


	struct {
#ifdef CONFIG_LARKFW_RADIO_FUNCTIONS
		/* (cached) ar9170_rf_init */

		/* PHY/RF state */
		unsigned int frequency;
		unsigned int ht_settings;

		enum lark_phy_state state;
		struct lark_psm psm;
#endif /* CONFIG_LARKFW_RADIO_FUNCTIONS */
	} phy;

	unsigned int tally_clock;
	struct lark_tally_rsp tally;
	unsigned int tx_time;
};

/*
 * global firmware context struct.
 *
 * NOTE: This struct will zeroed out in start()
 */
extern struct firmware_context_struct fw;
#endif /* __LARKFW_LARK_H */

